package com.googlecode.geoteacher.db.model;

/**
 * Model class for the game database table {@code challenge}.
 */
public class Challenge {
	
	/**
	 * Unique ID column.
	 */
	private long id;
	
	/**
	 * Unique SHA-256 hash of the challenge file.
	 */
	private String hash;
	
	/**
	 * Name of the challenge according to its challenge file.
	 */
	private String name;
	
	/**
	 * Path to the challenge file.
	 */
	private String path;

	public Challenge() {
	}

	public Challenge(String hash, String name, String path) {
		this.hash = hash;
		this.name = name;
		this.path = path;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((hash == null) ? 0 : hash.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Challenge other = (Challenge) obj;
		if (hash == null) {
			if (other.hash != null)
				return false;
		} else if (!hash.equals(other.hash))
			return false;
		if (id != other.id)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Challenge [id=" + id + ", hash=" + hash + ", name=" + name
				+ ", path=" + path + "]";
	}
}